import Vue from 'vue'
import VueRouter from 'vue-router'

// const routes = [
//   {
//     path: '/',
//     name: 'home',
//     component: HomeView
//   },
//   {
//     path: '/about',
//     name: 'about',
//     // route level code-splitting
//     // this generates a separate chunk (about.[hash].js) for this route
//     // which is lazy-loaded when the route is visited.
//     component: () => import(/* webpackChunkName: "about" */ '../views/AboutView.vue')
//   }
// ]

// 1.导入对应的组件
// @指项目中src文件夹
// node中包文件查找机制 自动查找文件夹中index
// import Reg from '@/views/reg'
// import Login from '@/views/login'
// import Main from '@/views/main'

// // 导入首页组件
// import Home from '@/views/menus/home'

// // 导入用户信息
// import UserInfo from '@/views/menus/user/userInfo.vue'
// import UserAvatar from '@/views/menus/user/userAvatar.vue'
// import UserPwd from '@/views/menus/user/userPwd.vue'

// // 导入文章信息
// import ArtCate from '@/views/menus/article/artCate.vue'
// import ArtList from '@/views/menus/article/artList.vue'

Vue.use(VueRouter)

// 2.书写路由的对应规则
const routes = [
  { path: '/reg', component: () => import('@/views/reg') },
  { path: '/login', component: () => import('@/views/login') },
  {
    path: '/',
    component: () => import('@/views/main'),
    // 路由重定向
    redirect: '/home',
    children: [
      { path: 'home', component: () => import('@/views/menus/home') },
      { path: 'user-info', component: () => import('@/views/menus/user/userInfo.vue') },
      { path: 'user-avatar', component: () => import('@/views/menus/user/userAvatar.vue') },
      { path: 'user-pwd', component: () => import('@/views/menus/user/userPwd.vue') },
      { path: 'art-cate', component: () => import('@/views/menus/article/artCate.vue') },
      { path: 'art-list', component: () => import('@/views/menus/article/artList.vue') }
    ]
  }
]

const router = new VueRouter({
  routes
})

export default router
